
num=[1, -2, 3, 5, -1]

max = num[0]

def function(lists):
    max=lists[0]
    pre_sum=0
    for i in lists:
        if pre_sum <0:
            pre_sum=i
        else:
            pre_sum+=i
        if pre_sum>max:
            max=pre_sum
    return max
print(function(num))
